import pymysql
from faker import Faker
import random
class DB:
    def __init__(self,host,user,password,database,cursoclass):
        self.host = host
        self.user = user
        self.password =password
        self.database = database
        self.curosclass = cursoclass
        self.faker = Faker(locale='zh_cn')
    def connect(self):
        self.db = pymysql.connect(host= self.host,user = self.user,password = self.password,database = self.database,cursorclass= self.curosclass)
        self.cursor = self.db.cursor
    def close(self):
        self.cousor.close()
        self.db.close()
    def insert_all(self,num):
        for i in range(num):
            name = self.faker.name()
            age = random.randint(18,55)
            address = self.faker.address

